﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
				   assembly="Triton.Modules.Media" 
				   namespace="Triton.Media.Model">
	<class name="Triton.Media.Model.Media, Triton.Modules.Media" table="media" xmlns="urn:nhibernate-mapping-2.2">
		<id name="Id" column="id" type="Int32">
			<generator class="hilo" />
		</id>
		<version name="Version" column="version" type="int" />

		<property name="Name" column="name" type="String" not-null="false" length="255"/>
		<property name="CreatedDate" column="created_date" not-null="false" type="DateTime"/>
		<property name="UpdatedDate" column="updated_date" not-null="false" type="DateTime"/>
		<property name="Comments" column="comments" type="string" not-null="false" length="500"/>
		<property name="SortOrder" column="sort_order" type="float" not-null="false" />
	
		<component class="Triton.Media.Model.FileRecord, Triton.Modules.Media" name="File">
			<property column="filename" name="Name" type="string" length="100"/>
			<property column="filepath" name="Path" type="string" length="200"/>
		</component>

		<many-to-one name="Type" column="media_type_id" class="Triton.Media.Model.MediaType, Triton.Modules.Media" foreign-key="FK_Media_MediaType"/>

		<bag name="RelatedMedia" table="media_2_media" generic="true">
			<key column="parent_media_id" foreign-key="FK_Media_Related_Media"/>
			<many-to-many class="Triton.Media.Model.Media, Triton.Modules.Media" column="child_media_id" foreign-key="FK_Related_Media_Media"/>
		</bag>

	</class>
</hibernate-mapping>